// pages/delete/delete.js
Page({
    data:{
        useId:'',
        cart:[
            {
                picture:'',
                proId:'',
                proNum:'',
                clothes_size:'',
                intro:'',
                price:'',
            }
        ]
    },
    change: function (e) {
        var that = this;
        e.detail.value = that.data.proNum;
    },
    queryCart(){
        var that = this;
        var app = getApp();
        that.data.useId = app.data.useId;
        wx.request({
            url: 'http://localhost:8080/cart/search?useId='+that.data.useId,
            method:'POST',
            header:{
                'content-type':'application/json'
            },
            success:function(res) {
                console.log(res);
                that.setData({
                    cart:res.data.data
                });
                console.log(that.data.cart)
            },
            fail:function() {
                console.log("失败");
            }
        })
    },
    // 删除
    deleteProduct(e){
        var that = this;
        var app = getApp();
        console.log(e.target.dataset.index.pro_id);
        var proId = e.target.dataset.index.pro_id;
        that.data.useId = app.data.useId;
        wx.request({
            url: 'http://localhost:8080/cart/delete?useId='+that.data.useId+'&proId='+proId,
            method:'POST',
            header:{
                'content-type':'application/json'
            },
            success:function(res) {
                console.log(res);
                that.queryCart();
                
            },
            fail:function() {
                console.log("失败");
            }
        })
    },
    onShow(){
        this.queryCart();
    }
})